const std = @import("std");
const allocator = @import("main.zig").allocator;

pub fn grow_capacity(raw: usize) usize {
    return if (raw < 8) 8 else 2 * raw;
}

pub fn grow_array(comptime T: type, old_ptr: ?[]T, new_size: usize) []T {
    return (if (old_ptr) |_old_ptr| allocator.realloc(_old_ptr, new_size) else allocator.alloc(T, new_size)) catch {
        @panic("failed to reallocate");
    };
}

pub fn free_array(ptr: anytype) void {
    allocator.free(ptr);
}
